package com.example.cinema.bindingdata;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.ImageView;

import androidx.databinding.BindingAdapter;
import androidx.databinding.ObservableField;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.cinema.R;

public class AdverItemData {

    @BindingAdapter("imgsurls")
    public static void GetImgUrl(View view,String url)
    {
        if(view==null||url==null)
        {
            return;
        }
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.defaut_img)
                .error(R.mipmap.defaut_img)
                .fallback(R.mipmap.defaut_img);
        Glide.with(view).load(url)
                .apply(options)
                .into((ImageView) view);
    }


    public void Clickss(View view,String url)
    {
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        view.getContext().startActivity(intent);
    }


    public ObservableField<String> images = new ObservableField<>();//图片地址
    public ObservableField<String>  skipurl = new ObservableField<>();//跳转地址

}
